package com.atgion.manager.controller;


import com.atgion.manager.service.AdminCategoryService;
import com.atgion.spzx.model.bo.blog.CategoryDO;
import com.atgion.spzx.model.vo.base.Result;
import com.atgion.spzx.model.vo.blog.AddCategoryReqVO;
import com.atgion.spzx.model.vo.blog.DeleteCategoryReqVO;
import com.atgion.spzx.model.vo.blog.QueryCategoryPageListReqVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 犬小哈
 * @url: www.quanxiaoha.com
 * @date: 2023-04-19 16:06
 * @description: TODO
 **/
@RestController
@RequestMapping("/admin/category")
public class AdminCategoryController {

    @Autowired
    private AdminCategoryService categoryService;

    @PostMapping("/add")
    @Operation(description = "新增分类")
    public Result addCategory(@RequestBody @Validated AddCategoryReqVO addCategoryReqVO) {
        return categoryService.addCategory(addCategoryReqVO);
    }

    @PostMapping("/list")
    @Operation(description = "获取分类列表分页数据")
    public Result<Page<CategoryDO>> queryCategoryPageList(@RequestBody QueryCategoryPageListReqVO queryCategoryPageListReqVO) {
        return categoryService.queryCategoryPageList(queryCategoryPageListReqVO);
    }

    @PostMapping("/delete")
    @Operation(description = "删除分类")
    public Result deleteCategory(@RequestBody @Validated DeleteCategoryReqVO deleteCategoryReqVO) {
        return categoryService.deleteCategory(deleteCategoryReqVO);
    }

    @PostMapping("/select/list")
    @Operation(description = "获取所有分类下拉框数据")
    public Result queryCategorySelectList() {
        return categoryService.queryCategorySelectList();
    }
}
